package com.whmall.service.crm.module.supplierchemicalcoa;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * COA来源类型
 *
 * @author alex
 * @since 2020/12/30
 */
public enum CoaSourceTypeEnum {
    /**
     * 询盘
     */
    INQUIRY(1),

    /**
     * 订单明细
     */
    ORDER_DETAIL(2),

    /**
     * 仓库库存
     */
    WAREHOUSE_INVENTORY(3),

    /**
     * 备货订单
     */
    STOCK_PURCHASE_ORDER(4);

    @JsonCreator
    public static CoaSourceTypeEnum fromNullableValue(Integer value) {
        if (null == value) {
            return null;
        }
        return fromValue(value);
    }

    public static CoaSourceTypeEnum fromValue(int value) {
        for (CoaSourceTypeEnum anEnum : values()) {
            if (anEnum.getValue() == value) {
                return anEnum;
            }
        }

        throw new UnsupportedOperationException("不支持的COA来源类型=" + value);
    }

    CoaSourceTypeEnum(int value) {
        this.value = value;
    }

    private final int value;

    @JsonValue
    public int getValue() {
        return value;
    }
}
